﻿using HardcoreGame.Content.Buffs;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;

namespace HardcoreGame.Common.GlobalItems
{
    public class CoffeeItem : GlobalItem
    {
        public override bool InstancePerEntity => true;
        protected override bool CloneNewInstances => true;
        public override void SetDefaults(Item item)
        {
            if (item.type == ItemID.CoffeeCup)
            {
                item.DefaultToFood(22, 22, ModContent.BuffType<RefreshOneself>(), 36000, useGulpSound: true);
            }
        }
        public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
        {
            if (item.type == ItemID.CoffeeCup)
            {
                string lineToFind = "Tooltip0";
                int targetIndex = tooltips.FindIndex(line => line.Name == lineToFind);
                if (targetIndex >= 0)
                {
                    tooltips.RemoveAt(targetIndex);
                    TooltipLine newLine = new(Mod, "CoffeeEffect", Language.GetTextValue("Mods.HardcoreGame.ToolTip.Coffee"));
                    tooltips.Insert(targetIndex, newLine);
                }
            }
        }
    }
}
